//
//  XueTangViewController.m
//  YYUnicode
//
//  Created by 蓓蕾 on 2021/7/31.
//

#import "XueTangViewController.h"
#import <AAChartKit.h>

@interface XueTangViewController ()

@property (nonatomic, strong) AAChartView *aaChartView;

@property (nonatomic, strong) AAChartModel *configureColumnrangeMixedLineChart;

@end

@implementation XueTangViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    NSLog(@"开始了");
    
    
    _aaChartView = [[AAChartView alloc]init];
    _aaChartView.frame = CGRectMake(10, 80, kScreenWidth - 20, 300);
    _aaChartView.scrollEnabled = NO;//是否允许滚动
    //_aaChartView.scrollEnabled = NO;
    [self.view addSubview:_aaChartView];
//    _aaChartView.userInteractionEnabled = NO;
    //有动画渲染
    [_aaChartView aa_drawChartWithChartModel:[self configureColumnrangeMixedLineChart]];
    //没有动画
//    [_aaChartView aa_drawChartWithOptions:[self disableChartAnimation]];
}
//没有动画渲染
- (AAOptions *)disableChartAnimation {
    AADataElement *aaDataElement = AADataElement.new
    .ySet(@85)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)//是否显示
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")//格式化文字
                   .ySet(@10)//自定义文字在y轴方向上的偏移
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement2 = AADataElement.new
    .ySet(@135)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement3 = AADataElement.new
    .ySet(@70)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement4 = AADataElement.new
    .ySet(@130)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement5 = AADataElement.new
    .ySet(@60)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
//                   .xSet(@0)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement6 = AADataElement.new
    .ySet(@115)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement7 = AADataElement.new
    .ySet(@55)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement8 = AADataElement.new
    .ySet(@110)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement9 = AADataElement.new
    .ySet(@50)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement10 = AADataElement.new
    .ySet(@100)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    
//    .aa_toAAOptions.plotOptions.series.animation = (id)@(false);
    
    AAChartModel *aaChartModel = AAChartModel.new
    .markerRadiusSet(@6)
    .legendEnabledSet(NO)//是否显示图例
    .yAxisVisibleSet(true)//y 轴是否可见(默认可见)
    .yAxisMinSet(@30)//设置Y轴最小值
    .yAxisGridLineStyleSet([AALineStyle styleWithWidth:@0])
    .markerSymbolStyleSet(AAChartSymbolStyleTypeBorderBlank)
    .chartTypeSet(AAChartTypeLine)//图表类型
    //X轴数据
    .categoriesSet(@[@"2019.6", @"2019.12", @"2020.4", @"2020.11", @"2021.5"])
//    .dataLabelsEnabledSet(true)//设置所有图表是否显示value值
    .colorsThemeSet(@[@"#ecf5ff",@"#3c90f7", @"#55bfc0"])
    .seriesSet(@[
        AASeriesElement.new
        .typeSet(AAChartTypeColumnrange)//图表类型【柱形图】
        .enableMouseTrackingSet(@NO)
        .dataSet(@[
            @[@85, @135],
            @[@70, @130],
            @[@60, @115],
            @[@55, @110],
            @[@50, @100],
        ]),
        AASeriesElement.new
        .typeSet(AAChartTypeLine)//图表类型【折线图】
        .enableMouseTrackingSet(@NO)
        .dataSet(@[aaDataElement, aaDataElement3, aaDataElement5, aaDataElement7, aaDataElement9]),
//        .dataSet(@[@135, @130, @115, @110, @100]),
        AASeriesElement.new
        .typeSet(AAChartTypeLine)//图表类型【折线图】【AAChartTypeSpline：曲线图】
        .enableMouseTrackingSet(@false)
        .dataSet(@[aaDataElement2, aaDataElement4, aaDataElement6, aaDataElement8, aaDataElement10]),
//        .dataSet(@[@85, @70, @60, @55, @50]),
    ]);
    
    AAOptions *aaOptions = aaChartModel.aa_toAAOptions;
    aaOptions.plotOptions.series.animation = (id)@(false);//禁用图表的渲染动画效果
    aaOptions.yAxis.gridLineDashStyle = AAChartLineDashStyleTypeLongDash;//设置Y轴的网格线样式为 AAChartLineDashStyleTypeLongDash
    return aaOptions;
}
//有动画渲染
- (AAChartModel *)configureColumnrangeMixedLineChart {
    AADataElement *aaDataElement = AADataElement.new
    .ySet(@85)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)//是否显示
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")//格式化文字
                   .ySet(@10)//自定义文字在y轴方向上的偏移
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement2 = AADataElement.new
    .ySet(@135)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement3 = AADataElement.new
    .ySet(@70)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement4 = AADataElement.new
    .ySet(@130)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement5 = AADataElement.new
    .ySet(@60)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
//                   .xSet(@0)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement6 = AADataElement.new
    .ySet(@115)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement7 = AADataElement.new
    .ySet(@55)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement8 = AADataElement.new
    .ySet(@110)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement9 = AADataElement.new
    .ySet(@50)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"低")
                   .ySet(@10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    AADataElement *aaDataElement10 = AADataElement.new
    .ySet(@100)
    .dataLabelsSet(AADataLabels.new
                   .enabledSet(true)
                   .verticalAlignSet(AAChartVerticalAlignTypeMiddle)
                   .formatSet(@"高")
                   .ySet(@-10)
                   .styleSet(AAStyleColorSizeWeight(AAColor.grayColor, 15, AAChartFontWeightTypeThin))
                   );
    
    return AAChartModel.new
//    .aa_toAAOptions.plotOptions.series.animation = (id)@(false);
    
    .markerRadiusSet(@6)
    .legendEnabledSet(NO)//是否显示图例
    .yAxisVisibleSet(true)//y 轴是否可见(默认可见)
    .yAxisGridLineStyleSet([AALineStyle styleWithWidth:@0])
    .markerSymbolStyleSet(AAChartSymbolStyleTypeBorderBlank)
    .chartTypeSet(AAChartTypeLine)//图表类型
    //X轴数据
    .categoriesSet(@[@"2019.6", @"2019.12", @"2020.4", @"2020.11", @"2021.5"])
//    .dataLabelsEnabledSet(true)//设置所有图表是否显示value值
    .colorsThemeSet(@[@"#ecf5ff",@"#3c90f7", @"#55bfc0"])
    .seriesSet(@[
        AASeriesElement.new
        .typeSet(AAChartTypeColumnrange)//图表类型【柱形图】
        .enableMouseTrackingSet(@NO)//是否允许交互
        .dataSet(@[
            @[@85, @135],
            @[@70, @130],
            @[@60, @115],
            @[@55, @110],
            @[@50, @100],
        ]),
        AASeriesElement.new
        .typeSet(AAChartTypeLine)//图表类型【折线图】
        .enableMouseTrackingSet(@NO)
        .dataSet(@[aaDataElement, aaDataElement3, aaDataElement5, aaDataElement7, aaDataElement9]),
//        .dataSet(@[@135, @130, @115, @110, @100]),
        AASeriesElement.new
        .typeSet(AAChartTypeLine)//图表类型【折线图】【AAChartTypeSpline：曲线图】
        .enableMouseTrackingSet(@false)
        .dataSet(@[aaDataElement2, aaDataElement4, aaDataElement6, aaDataElement8, aaDataElement10]),
//        .dataSet(@[@85, @70, @60, @55, @50]),
    ]);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
